var WxParse = require("../../../wxParse/wxParse.js"), app = getApp();

Page({
    data: {},
    onLoad: function(a) {
        wx.setNavigationBarColor({
            frontColor: "#ffffff",
            backgroundColor: app.globalData.toubu_color
        });
        var t = a.id, n = this;
        n.setData({
            jiang: t
        }), app.util.request({
            url: "entry/wxapp/pxjiangpinxq",
            method: "POST",
            data: {
                id: t
            },
            success: function(a) {
                var t = a.data.data, o = a.data.data.content;
                WxParse.wxParse("article", "html", o, n, 5), n.setData({
                    goods: t
                });
            },
            fail: function(a) {
                console.log("失败");
            }
        });
    },
    Challenge: function(a) {
        var r = this;
        app.util.request({
            url: "entry/wxapp/pxlingjiang",
            method: "POST",
            data: {
                user_id: app.globalData.user_id,
                id: r.data.jiang
            },
            success: function(a) {
                var t = a.data.data.lj_stact;
                r.setData({
                    lj_stact: t
                }), 0 == t ? wx.showModal({
                    title: "提示",
                    content: "您不能领取该奖品",
                    success: function(a) {
                        a.confirm && console.log("用户点击确定");
                    }
                }) : wx.chooseAddress({
                    success: function(a) {
                        var t = a.userName, o = a.postalCode, n = a.provinceName, e = a.cityName, s = a.countyName, i = a.detailInfo, c = a.telNumber, l = a.nationalCode;
                        app.util.request({
                            url: "entry/wxapp/pxfajiang",
                            method: "POST",
                            data: {
                                lj_stact: r.data.lj_stact,
                                user_id: app.globalData.user_id,
                                stact: r.data.stacrrt,
                                userName: t,
                                postalCode: o,
                                provinceName: n,
                                cityName: e,
                                countyName: s,
                                detailInfo: i,
                                telNumber: c,
                                nationalCode: l
                            },
                            success: function(a) {
                                1 == a.data.data && (wx.showModal({
                                    title: "提示",
                                    content: "领取成功",
                                    success: function(a) {
                                        a.confirm ? console.log("用户点击确定") : a.cancel && console.log("用户点击取消");
                                    }
                                }), r.jiangpin());
                            }
                        });
                    }
                });
            }
        });
    },
    onReady: function() {},
    tiao: function() {
        app.globalData.indexOf = 1, wx.navigateBack({
            delta: 1
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});